//
//  HuiyuanCanyuTableViewCell.m
//  XRSquare
//
//  Created by UaenaMo on 2018/8/15.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "HuiyuanCanyuTableViewCell.h"

@interface HuiyuanCanyuTableViewCell ()
{
    NSDictionary * cur;
    UIImageView * imageView;
    UILabel * titleLabel;
    UILabel * timeLabel;
    UIButton * actionButton;
}
@end

@implementation HuiyuanCanyuTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 50, 50)];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.clipsToBounds = YES;
        [self addSubview:imageView];
        
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 10, ScreenWidth, 20)];
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:titleLabel];
        
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 40, ScreenWidth, 20)];
        timeLabel.font = [UIFont systemFontOfSize:12];
        timeLabel.textColor = [UIColor colorFromHexCode:@"b3b3b3"];
        [self addSubview:timeLabel];
        
        actionButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 70, 25)];
        actionButton.center = CGPointMake(ScreenWidth - 45, 35);
        actionButton.layer.cornerRadius = 5;
        actionButton.titleLabel.font = [UIFont systemFontOfSize:13];
        actionButton.backgroundColor = [UIColor colorFromHexCode:@"b3b3b3"];
        [actionButton setTitle:@"取消申请" forState:UIControlStateNormal];
        [actionButton addTarget:self action:@selector(actionButtonAction) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:actionButton];
        
        UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 69, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
    }
    return self;
}

+(CGFloat)height
{
    return 70;
}

-(void)loadData:(NSDictionary *)data
{
    cur = data;
    [imageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://pic.xrsquare.com/%@",[data objectForKey:@"HeadPic"]]]];
    titleLabel.text = [data objectForKey:@"Name"];
    timeLabel.text = [data objectForKey:@"Time"];
}

-(void)actionButtonAction
{
    [self.delegate cancleW:cur];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
